package com.listeningframework.boot.autoconfigure.template.thymeleaf;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.thymeleaf.spring4.SpringTemplateEngine;

import com.listeningframework.boot.autoconfigure.template.thymeleaf.dialect.ListeningThymeleafDialect;
import com.listeningframework.boot.autoconfigure.template.thymeleaf.processors.HelloWorldProcessor;

/**
 * 
 * Listening Thymeleaf Configuration
 *
 * @author lixining
 * @version $Id: ListeningThymeleafConfiguration.java, v 0.1 2016年7月1日 下午6:44:20 lixining Exp $
 */
@Configuration
@ConditionalOnClass(SpringTemplateEngine.class)
@AutoConfigureAfter(ThymeleafAutoConfiguration.class)
public class ListeningThymeleafConfiguration {

    /**
     * ListeningThymeleafDialect ls:test
     *
     * @return ListeningThymeleafDialect
     */
    @Bean
    @ConditionalOnMissingBean(ListeningThymeleafDialect.class)
    public ListeningThymeleafDialect getListeningThymeleafDialect() {
        return new ListeningThymeleafDialect();
    }

    /**
     * HelloWorldProcessor
     *
     * @return HelloWorldProcessor
     */
    @Bean
    @ConditionalOnMissingBean(HelloWorldProcessor.class)
    public HelloWorldProcessor getHelloWorldProcessor() {
        return new HelloWorldProcessor();
    }
}
